home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: BALROG.NCI.NIH.GOV!SYSTEX
- From: systex@BALROG.NCI.NIH.GOV (Donald G. Plugge, Systex Inc., (301)210-7701)
- Subject: VMS Descriptors in C++?
- Message-ID: <1996Feb7.143723.25305@alw.nih.gov>
- Sender: postman@alw.nih.gov (AMDS Postmaster)
- Nntp-Posting-Host: balrog.nci.nih.gov
- Reply-To: systex@BALROG.NCI.NIH.GOV
- Organization: Organization, City, State, etc.
- Date: Wed, 7 Feb 1996 14:37:23 GMT
-
-
-
- In the spirit of object oriented programming, I'd like to ask a design question
- in order to determine which C++ component to utilize in a particular case. I
- have experience with C, however, I have just begun to explore the vast
- assortment of features available in C++. My questions concerns the string
- class and whether to include, cast or inherit them into another structure.
-
- My coding is done on an Alpha 3400 running VMS 6.1 with DEC C++ version 3.1.
- In the VMS environment system service calls use a structure called a descriptor
- to pass character data. The definition of the structure is contained in the
- <descrip.h> file. The relevant section follows below. Notice that the code
- #defines a $DESCRIPTOR macro to place an array of characters into the
- descriptor structure. The new descriptor is then ready to be passed to the
- system service.
-
- /*
- * Fixed-Length Descriptor:
- */
- struct dsc$descriptor_s
- {
- unsigned short dsc$w_length; /* length of data item in bytes,
- or if dsc$b_dtype is DSC$K_DTYPE_V, bits,
- or if dsc$b_dtype is DSC$K_DTYPE_P, digits (4 bits each) */
- unsigned char dsc$b_dtype; /* data type code */
- unsigned char dsc$b_class; /* descriptor class code = DSC$K_CLASS_S */
- char *dsc$a_pointer; /* address of first byte of data storage */
- };
-
-
- /*
- * A simple macro to construct a string descriptor:
- */
- #define $DESCRIPTOR(name,string) struct dsc$descriptor_s name = { sizeof(string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
-
- An example of a call to the macro would be:
-
-
- dsc$descriptor_s dsc;
- $DESCRIPTOR(dsc, "XYZ");
- status = SYS$GETDVI (0, 0, &dsc, &itmlst[0], &iosb, 0, 0, 0);
-
- The $DESCRIPTOR syntax only takes literal character array and not a Class
- strings. If I create a subroutine to call the system service by passing a
- literal character array, that works fine. However, if I pass a string object,
- then the $DESCRIPTOR fails.
-
- Would it be wise to create a descriptor class which is derived from a string
- class? From what I've been reading in "Effective C++" by Meyers the derived
- class "isa" base class. So, the derived descriptor should really be a string,
- but that doesn't seem to fit. Perhaps the descriptor class should contain a
- member function which returns the proper descriptor. Or perhaps I shouldn't
- use the DEC provided descrip.h at all and create a new structure based upon
- the string class.
-
- Any thoughts about what is good and proper?
-
-
- Donald G. Plugge
-
-